package arsmodeller.editpolicies;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;

import arsmodeller.commands.LinkCreateCommand;
import arsmodeller.model.Thing;
import arsmodeller.model.Link;

public class ThingGraphicalNodePolicy extends GraphicalNodeEditPolicy {

	@Override
	protected Command getConnectionCompleteCommand(
			CreateConnectionRequest request) {
		LinkCreateCommand result = (LinkCreateCommand) request
				.getStartCommand();
		result.setTarget((Thing) getHost().getModel());
		return result;
	}

	@Override
	protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
		LinkCreateCommand result = new LinkCreateCommand();
		result.setSource((Thing) getHost().getModel());
		result.setLink((Link) request.getNewObject());
		result.setOPD(((Thing) getHost().getModel()).getOpd());
		request.setStartCommand(result);
		return result;
	}

	@Override
	protected Command getReconnectTargetCommand(ReconnectRequest request) {
		return null;
	}

	@Override
	protected Command getReconnectSourceCommand(ReconnectRequest request) {
		return null;
	}
}